package com.humngyang.com.hmy.study.concurrency.myannoations.aqs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.*;

public class FutureTaskExample {
    private static Logger log = LoggerFactory.getLogger(FutureTaskExample.class);

    public static void main(String[] args) throws Exception {
        FutureTask futureTask = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                log.info(" do something in callalbe");
                Thread.sleep(3000);
                return "done";
            }
        });
        new Thread(futureTask).start();
        log.info("do something in main");
        Thread.sleep(1000);
        String result = (String) futureTask.get();
        log.info("result {}",result);
    }
}

